$(function() {
	layui.use('layer', function(){
		var layer = layui.layer;
		$("#login").click(function(){
			var username = $("#username").val()
			var password = $("#password").val()
			$.ajax({
				url: "http://localhost:8081/login",
				type: "POST",
				async: false,
				data:{
					"username":username,
					"password":password
				},//请求数据s
				success:function(data){
					if(data.code == 0){
						sessionStorage.setItem("token",JSON.stringify(data.data.token));
						sessionStorage.setItem("username",JSON.stringify(data.data.username));
						window.location.href="/AMS/index.html"
					}else{
						layer.msg("登录失败",{icon:5,time:1000});
					}
				},
				error:function(){
					layer.msg("登录失败",{icon:5,time:1000});
				}
			})	
		})
	});
})